<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('web_menus', function (Blueprint $table) {
            $table->id();
            $table->integer('parent_id')->default(0)->comment('父级Id');
            $table->string('parent_ids',255)->default('')->comment('父级Id集合');
            $table->tinyInteger('level')->default(0)->comment('菜单等级');
            $table->tinyInteger('type')->default(0)->comment('栏目类别');
            $table->string('name', 50)->default('')->comment('菜单名称');
            $table->string('link',500)->default('')->comment('栏目链接');
            $table->tinyInteger('pinyin')->default(0)->comment('栏目拼音:1=是,0=否');
            $table->tinyInteger('show_child')->default(0)->comment('默认展示第一个子集:1=是,0=否');
            $table->string('module_page', 100)->default('')->comment('模板页面');
            $table->string('banner',500)->default('')->comment('banner图片');
            $table->string('banner_link',500)->default('')->comment('banner跳转链接');
            $table->string('banner_title',100)->default('')->comment('banner标题');
            $table->string('banner_desc',100)->default('')->comment('banner介绍');
            $table->longText('content')->default('')->comment('栏目内容');
            $table->string('seo_title', 80)->default('')->comment('SEO标题');
            $table->string('seo_keywords', 100)->default('')->comment('SEO关键词');
            $table->string('seo_description', 200)->default('')->comment('SEO介绍');
            $table->integer('sort')->default(0)->comment('排序:数字越小越靠前');
            $table->tinyInteger('status')->default(0)->comment('状态:1=正常,2=禁用');
            $table->tinyInteger('is_delete')->default(0)->comment('是否删除:1=删除,0=正常');
            $table->integer('created_at')->default(0)->comment('创建时间');
            $table->integer('updated_at')->default(0)->comment('修改时间');
        });
        DB::statement("ALTER TABLE `web_menus` comment '【网站】菜单管理'");
        $list_id = DB::table('admin_menus')->insertGetId([
            'name'        => '栏目管理',
            'path'        => 'arts/manage/web_menus',
            'icon'        => 'el-icon-menu',
            'module_type' => 'extend',
            'level'       => 1,
            'facility'    => 1,
            'sort'        => 255,
            'status'      => 1,
            'created_at'  => time()
        ]);
        DB::table('admin_menus')->insert([
            [
                'parent_id'   => $list_id,
                'name'        => '新增',
                'path'        => 'arts/manage/web_menus/insert',
                'action'      => 'insert',
                'icon'        => 'el-icon-circle-plus-outline',
                'level'       => 2,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'parent_id'   => $list_id,
                'name'        => '编辑',
                'path'        => 'arts/manage/web_menus/update',
                'action'      => 'update',
                'icon'        => 'el-icon-edit',
                'level'       => 2,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'parent_id'   => $list_id,
                'name'        => '删除',
                'path'        => 'arts/manage/web_menus/remove',
                'action'      => 'remove',
                'icon'        => 'el-icon-delete',
                'level'       => 2,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'parent_id'   => $list_id,
                'name'        => '状态',
                'path'        => 'arts/manage/web_menus/status',
                'action'      => 'status',
                'icon'        => 'el-icon-warning',
                'level'       => 2,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ]
        ]);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('web_menus');
    }
};
